package com.zggk.iroad.log.logmx;


import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zggk.iroad.R;
import com.zggk.iroad.db.DcLxInfo;
import com.zggk.iroad.db.EntityManager;
import com.zggk.iroad.greendao.DcLxInfoDao;
import com.zggk.iroad.mvp.MVPBaseActivity;
import com.zggk.iroad.util.NoScroolGridView;
import com.zggk.iroad.util.ShowGridAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class LogMxActivity extends MVPBaseActivity<LogMxContract.View, LogMxPresenter> implements LogMxContract.View {

    @Bind(R.id.back)
    ImageView back;
    @Bind(R.id.title_text)
    TextView titleText;
    @Bind(R.id.cancle_button)
    TextView cancleButton;
    @Bind(R.id.jlry_te)
    TextView jlryTe;
    @Bind(R.id.jlry_lay)
    LinearLayout jlryLay;
    @Bind(R.id.xcry_te)
    EditText xcryTe;
    @Bind(R.id.xcry_lay)
    LinearLayout xcryLay;
    @Bind(R.id.lx_te)
    TextView lxTe;
    @Bind(R.id.lx_lay)
    LinearLayout lxLay;
    @Bind(R.id.xcsj_te)
    TextView xcsjTe;
    @Bind(R.id.xcsj_lay)
    LinearLayout xcsjLay;
    @Bind(R.id.xctq_te)
    TextView xctqTe;
    @Bind(R.id.xctq_lay)
    LinearLayout xctqLay;
    @Bind(R.id.xclx_te)
    TextView xclxTe;
    @Bind(R.id.xclx_lay)
    LinearLayout xclxLay;
    @Bind(R.id.xcnr_lay)
    LinearLayout xcnrLay;
    @Bind(R.id.xcnr_et)
    EditText xcnrEt;
    @Bind(R.id.cljl_lay)
    LinearLayout cljlLay;
    @Bind(R.id.cljl_et)
    EditText cljlEt;
    @Bind(R.id.czwt_lay)
    LinearLayout czwtLay;
    @Bind(R.id.czwt_et)
    EditText czwtEt;
    @Bind(R.id.cljy_lay)
    LinearLayout cljyLay;
    @Bind(R.id.cljy_et)
    EditText cljyEt;
    @Bind(R.id.tjtp_lay)
    LinearLayout tjtpLay;
    @Bind(R.id.add_pic_grid)
    NoScroolGridView addPicGrid;
    @Bind(R.id.add_pic_lay)
    LinearLayout addPicLay;
    private DcLxInfoDao dcLxInfoDao;


    @Override
    public void onRequestError(String msg) {

    }

    @Override
    protected int getLayout() {
        return R.layout.act_log_mx;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        initData();
        initView();
    }

    private void initData() {
        mPresenter.testinfo(getIntent().getStringExtra("RZID"));
    }

    private void initView() {
        titleText.setText("日志详情");
    }

    @OnClick({R.id.back, R.id.title_text, R.id.cancle_button})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.title_text:
                break;
            case R.id.cancle_button:
                break;
        }
    }

    @Override
    public void getData(LogMxBean videoVos2) {
        dcLxInfoDao = EntityManager.getInstance().getDcLxInfoDao();
        jlryTe.setText(videoVos2.getXcrzMx().get(0).getCREATOR());//记录人员
        xcryTe.setText(videoVos2.getXcrzMx().get(0).getXCR());//巡查人
        lxTe.setText(videoVos2.getXcrzMx().get(0).getLDMC());//路段名称
        xcsjTe.setText(videoVos2.getXcrzMx().get(0).getXCSJ());//巡查时间
        xctqTe.setText(videoVos2.getXcrzMx().get(0).getTQ());//巡查天气
        List<DcLxInfo> SSS = dcLxInfoDao.queryBuilder().where(DcLxInfoDao.Properties.VALUE.eq(videoVos2.getXcrzMx().get(0).getXCXZ())).limit(1).list();
        xclxTe.setText(SSS.get(0).getTEXT());//调查类型
        xcnrEt.setText(videoVos2.getXcrzMx().get(0).getXCNR());//巡查内容
        cljlEt.setText(videoVos2.getXcrzMx().get(0).getCLJL());//处理记录
        czwtEt.setText(videoVos2.getXcrzMx().get(0).getCZWT());//存在问题
        cljyEt.setText(videoVos2.getXcrzMx().get(0).getCLYQ());//处理建议
        ArrayList<String> listImgUrl = new ArrayList<>();
        if (videoVos2.getPIC() != null && videoVos2.getPIC().size() > 0) {
            for (int i = 0; i < videoVos2.getPIC().size(); i++) {
                listImgUrl.add(videoVos2.getPIC().get(i).getFILEPATH());
            }
        }
        ShowGridAdapter showGridAdapter = new ShowGridAdapter(this, listImgUrl);
        addPicGrid.setAdapter(showGridAdapter);
    }
}

